'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, STRING, UUID, ENUM } = Sequelize;
    await queryInterface.createTable('users', {
      id: { type: INTEGER, primaryKey: true, unique: true, autoIncrement: true },
      uuid: { type: UUID, defaultValue: Sequelize.UUIDV4 },
      nickname: { type: STRING, allowNull: false },
      sex: { type: ENUM, values: [ 'male', 'female', 'unknown' ] },
      tel: { type: STRING(11), allowNull: false, unique: true, is: /^1(3|4|5|6|7|8|9)\d{9}$/, validate: { notNull: { msg: '请输入你的手机号' } } },
      avatar: { type: STRING },
      password: { type: STRING, allowNull: false, validate: { notNull: { msg: '请输入你的密码' } } },
      username: { type: STRING(50) },
    });
  },

  down: async (queryInterface, Sequelize) => {
    console.log(Sequelize);
    await queryInterface.dropTable('users');
  },
};
